/**
  ******************************************************************************
  * @file    operation_protocol.h
  * @brief   运营平台协议处理
  ******************************************************************************
  */

#ifndef __OPERATION_PROTOCOL_H
#define __OPERATION_PROTOCOL_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "operation_protocol_data_def.h"

#define OPERATION_LINKKIT_AUTH    0
#define OPERATION_LINKKIT_POLL    1

#define OPERATION_LINKKIT_AUTH_FAULT    (-1)
#define OPERATION_LINKKIT_AUTH_WAIT     (-2)
#define OPERATION_LINKKIT_POLL_FAULT    (-3)

/**
 * @brief init handle.
 *---
 * @param ops_eth, ops_host, ops_port
 * @return do not free -1, free 0.
 * @see None.
 * @note None.
 */
int32_t ops_linkkit_new(char *ops_eth, char *ops_host, uint16_t ops_port);

/**
 * @brief free handle.
 *---
 * @param None.
 * @return do not free -1, free 0.
 * @see None.
 * @note None.
 */
int32_t ops_linkkit_free(void);

/**
 * @brief network deinit.
 *---
 * @param None.
 * @return core_sysdep_network_deinit().
 * @see None.
 * @note None.
 */
int32_t ops_network_deinit(uint8_t gunno);

/**
 * @brief device authentication.
 *---
 * @param [in] param: @n the auth data will be written.
 * @param [in] len: @n the auth data len will be written.
 * @return do not free -1, free 0.
 * @see None.
 * @note None.
 */
int32_t ops_auth(uint8_t gunno, void *param, uint32_t len);

/**
 * @brief yield.
 *---
 * @param None.
 * @return aiot_itcp_recv().
 * @see None.
 * @note None.
 */
int32_t ops_yield(uint8_t gunno);

/**
 * @brief 发送桩事件数据发送到运营平台.
 *---
 * @param [in] event_type: @n the event you want to send.
 * @param [in] param: @n the event data will be written.
 * @return None.
 * @see None.
 * @note None.
 */
void ops_send_event(uint8_t gunno, ops_cmd_event_enum event_type, void *param);

/**
 * @brief 发送桩属性数据发送到运营平台.
 * @param [in] event_type: @n the property you want to send.
 * @param [in] param: @n the property data will be written.
 * @return None.
 * @see None.
 * @note None.
 */
void ops_send_property(uint8_t gunno, ops_cmd_property_enum property_type, void *param);

#ifdef __cplusplus
}
#endif

#endif /* __OPERATION_PROTOCOL_H */
